import java.util.Queue;
import java.util.Stack;

public class MyQueueUseStack {//用栈来实现队列
    public Stack<Integer>s2;
    public Stack<Integer>s1;

    public MyQueueUseStack() {
        s1=new Stack<>();
        s2=new Stack<>();
    }
    public  int peek(){
        if (empty()){
            return -1;
        }
        if (s2.empty()){
            while (!s1.empty()){
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }
    public void push(int x){
        s1.push(x);//都push进s1里面
    }
    public int pop(){//
        if (empty()){
            return -1;
        }
    if (s2.empty()){//如果2空了就把1中的都放进2，然后再pop 2中的元素
        while (!s1.empty()){
            s2.push(s1.pop());
        }
    }
   return s2.pop();
    }

    public boolean empty(){
    return s1.empty()&&s2.empty();
}
}
